<html>

<head>

</head>

<body>
    <div id="app">
        {{msg}}
        <div>
            <input type="text" v-model="info" />
            <button @click="handlerClick">添加</button>
        </div>
        <ul>
            <li v-for="item in list" >{{item}}</li>
        </ul>

        <ul>
            <todo-item v-for="item in list" v-bind:item='item'/>
            
        </ul>

        <ul>
            <todo-item v-for="item in list" :item='item'/>
        </ul>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
        //自定义组件
        Vue.component('todo-item', {
            props:['item'],
            template: '<li>{{item}}</li>'
        });
        new Vue({
            el: "#app",
            data() {
                return {
                    msg: 'hello vue',
                    info: '',
                    list: []
                }
            },
            methods: {
                handlerClick() {
                    console.log(this.info);
                    this.list.push(this.info);
                    this.info = '';
                }
            }
        })
    </script>
</body>

</html>